package com.utf999.qiangmanger.utils;

import org.springframework.security.authentication.encoding.Md5PasswordEncoder;
import org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder;

public class MD5Utils {

	/**
	 * 加密方式1
	 * @param password
	 * @param username
	 * @return
	 */
	public static String encoder(String password,String username){
		Md5PasswordEncoder md5PasswordEncoder = new Md5PasswordEncoder();
		return md5PasswordEncoder.encodePassword(password, username);
	}
	
	/**
	 * 加密方式2
	 * @param password
	 * @return
	 */
	public static String encoder(String password) {
		MessageDigestPasswordEncoder encoder = new MessageDigestPasswordEncoder("md5");
		encoder.setEncodeHashAsBase64(false);
		return encoder.encodePassword(password, null);
	}
}
